﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;

namespace LakeSide.Core.Session
{
    /// <summary>
    /// Session类
    /// </summary>
    public class SeesionManager
    {
        /// <summary>
        /// 添加obj到Session
        /// </summary>
        /// <param name="Key">键</param>
        /// <param name="Obj">object对象</param>
        public static void InsertObject(string Key, object Obj)
        {
            if ((Obj != null))
            {
                if (HttpContext.Current.Session[Key] == null)
                {
                    HttpContext.Current.Session[Key] = Obj;
                }
            }
        }

        /// <summary>
        /// 得到Session对象
        /// </summary>
        /// <param name="Key">键</param>
        /// <returns></returns>
        public static object GetObject(string Key)
        {
            return HttpContext.Current.Session[Key];
        }

        /// <summary>
        /// 移除Session
        /// </summary>
        /// <param name="Key">键</param>
        public static void RemoveObject(string Key)
        {
            if ((HttpContext.Current.Session[Key] != null))
            {
                HttpContext.Current.Session[Key] = null;
            }
        }
    }
}
